/**
  * @brief  定时器的回调函数
  * @param  None
  * @retval None
  */
void init_timer(void)
{
    //  //一定时间的定时器
    //  os_timer_disarm( &os_timer );
    //  os_timer_setfn( &os_timer, (os_timer_func_t *) timer_callback, NULL );
    //  os_timer_arm( &os_timer, 2000, true );
}

/**
  * @brief  被主函数主循环loop周期调用
  * @param  None
  * @retval None
  */
void loop_callback()
{
    static int humi_last = -1, temp_last = -1;
    humi_read = (int)(SHT2x.GetHumidity() * 10);
    temp_read = (int)(SHT2x.GetTemperature() * 10);

    //第一次给last赋初值 保证是一个比较正确的值
    if ((humi_read > 0) && (humi_read < 1000) && (humi_last == -1))
    {
        humi_last = humi_read;
    }
    if ((temp_read > 0) && (temp_read < 500) && (temp_last == -1))
    {
        temp_last = temp_read;
    }

    isright = ((abs(humi_read - humi_last) < 100) && (abs(temp_read - temp_last) < 100));
    humi_read = (abs(humi_read - humi_last) < 100) ? humi_read : humi_last; //湿度误差小于10%
    temp_read = (abs(temp_read - temp_last) < 100) ? temp_read : temp_last; //湿度误差小于10度
    humi_last = humi_read;
    temp_last = temp_read;

    Number3.print(humi_read);
    Number2.print(temp_read);

    unknow_module("print humi & temp");
    BLINKER_LOG("Humidity: ", humi_read, " %");
    BLINKER_LOG("Temperature: ", temp_read, " *C");
}
